package com.zzxy.springmvc5.controler;

import com.zzxy.springmvc5.po.Student;
import com.zzxy.springmvc5.po.studentExt;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @RequestMapping("/register1.do")
    public String register(){
        return "/user/register";
    }

    @RequestMapping("insertStu")
    public @ResponseBody Student register1(@RequestBody Student student){
        student.setUsername(student.getUsername()+"123");
        student.setPassword(student.getPassword()+"456");
        return student;
    }
    @RequestMapping("addStu")
    public String addStu(String username,String password){
        System.out.println(username);
        System.out.println(password);
        return "/user/list";
    }
    @RequestMapping("addStu1")
    public String addStu1(Student student){
//        System.out.printf("student",student);
        System.out.println(student.toString());
        return "/user/list";
    }
    @RequestMapping("addStu2")
    public String addStu1(studentExt ext){
        System.out.println(ext);
        return "/user/list";
    }
    @RequestMapping("test")
    public String test(){
        return "forward:/stu/register.do";
    }
    @RequestMapping("test1")
    public String test1(){
        return "redirect:/stu/register.do";
    }
}
